package com.mz.ozy.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mz.ozy.R;
import com.mz.ozy.bean.GoodsListBean;
import com.mz.ozy.bean.HomeMerBean;
import com.mz.ozy.utils.glideUtils.GlideUtils;
import com.mz.ozy.widget.CustomRoundAngleImageView;

import java.util.List;

/**
 * @author lifeStyle on 2020/4/3 0003.
 */
public class ObShopListAdapter extends BaseQuickAdapter<GoodsListBean.GoodsPageBean.PageItemsBean, BaseViewHolder> {


    public ObShopListAdapter(List<GoodsListBean.GoodsPageBean.PageItemsBean> data) {
        super(R.layout.item_search_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsListBean.GoodsPageBean.PageItemsBean item) {
        helper.setText(R.id.tv_goods_name, item.getTradename());
        helper.setText(R.id.tv_benifit_kind, item.getDescribed());
        helper.setVisible(R.id.tv_unit_price, false);
        helper.setText(R.id.tv_goods_price, item.getPrice() + " 欧花");


        CustomRoundAngleImageView ivGoodsPic = helper.getView(R.id.iv_goods_pic);
        String imgUrl = "";
        if (!TextUtils.isEmpty(item.getImg_zt())) {
            final String[] img_arr = item.getImg_zt().trim().split(",");
            if (img_arr.length > 0) {
                imgUrl = img_arr[0];
            }
        }
        GlideUtils.loadRoundImg(mContext, ivGoodsPic, imgUrl, R.mipmap.default_foods_icon, 4);


        helper.addOnClickListener(R.id.ll_item_view);
        helper.addOnClickListener(R.id.iv_search_car);
    }
}
